import React from 'react'
import Icon from '@/components/Icon'
import styles from './index.module.scss'
import { useHistory } from 'react-router'
import classNames from 'classnames'
export default function NavBar({
  children,
  rightEvent,
  rightContent,
  leftEvent,
  className,
}) {
  const history = useHistory()
  const defaultClick = () => {
    history.go(-1)
  }
  return (
    <div className={classNames(styles.navBar, className)}>
      {/* 后退按钮 */}
      <div className="left" onClick={leftEvent || defaultClick}>
        <Icon type="iconfanhui" />
      </div>
      {/* 居中标题 */}
      <div className="title">{children}</div>

      {/* 右侧内容 */}
      <div className="right" onClick={rightEvent}>
        {rightContent}
      </div>
    </div>
  )
}
